package com.example.mq.lock;
import java.util.function.Consumer;
import java.util.function.Function;
/*
@description:
@ClassName DistributeLock
@author chen
@create 2025-08-14 18:03
@Version 1.0
*/
public interface DistributeLock
{
    /*
     * 上锁执行业务操作，上锁失败返回false
     * @param lockKey
     * @param consumer
     * @return
     */
    boolean accept(String lockKey, Consumer<String> consumer);

    /*
     * 上锁执行业务操作
     * @param lockKey
     * @param consumer
     * @param lockFailException 上锁失败将抛出异常
     * @return
     */
    void accept(String lockKey, Consumer<String> consumer, Function<String, ? extends RuntimeException> lockFailException);
}
